package graphicEngine;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

/**
 *
 * @author Rémi Dubois <RemiEric.Dubois@gmail.com>
 */
public class GameWindow  extends JFrame implements KeyListener{
    
    private GameDisplay gameDisplay;
    
    public GameWindow() {
        super("Nao Evolution Soccer 2012");

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(false);
    }
    
    
    public GameDisplay getGameDisplay() {
        return gameDisplay;
    }

    /**
     * @param gameDisplay the gameDisplay to set
     */
    public void setGameDisplay(GameDisplay gameDisplay) {
        this.gameDisplay = gameDisplay;
        
        this.setContentPane(gameDisplay);
        this.pack();
        this.setVisible(true);
    }
    
    
    //debug part
    
    @Override
	public void keyPressed(KeyEvent e) 
	{		
		switch (e.getKeyCode())
		{
		case KeyEvent.VK_DOWN :
			gameDisplay.dir = (float) (-Math.PI/2);
			gameDisplay.spe = 1.0f;
			break;
		case KeyEvent.VK_LEFT :
			gameDisplay.dir = (float) (Math.PI);
			gameDisplay.spe = 1.0f;
			break;
		case KeyEvent.VK_UP :
			gameDisplay.dir = (float) (Math.PI/2);
			gameDisplay.spe = 1.0f;
			break;
		case KeyEvent.VK_RIGHT :
			gameDisplay.dir = (float) (0.0);
			gameDisplay.spe = 1.0f;
			break;
		default :
			System.out.println(e.getKeyCode());
		}	
		
		System.out.println("test");
	}

	@Override
	public void keyReleased(KeyEvent e) 
	{
		gameDisplay.spe = 0.0f;
	}

	@Override
	public void keyTyped(KeyEvent e) 
	{		
	}
}